<?php
class WebUser extends CWebUser {
    
    private $LoginForm;
    
    protected function loadUser($id=null)
    {
        if($this->LoginForm===null)
        {
            if($id!==null)
            {
                $this->LoginForm = User::model()->findByPk($id);
            }
        }
        return $this->LoginForm;
    }
    
    public function isAdmin()
    {
        $user = $this->loadUser(Yii::app()->user->id);
        if($user)
        {
            if($user->role_id==1)
            {
                return true;
            }
        }
        return false;
    }
    
    public function isOperator()
    {
        $user = $this->loadUser(Yii::app()->user->id);
        if($user)
        {
            if($user->role_id==2)
            {
                return true;
            }
        }
        return false;
    }
    //Validate Operator Pengolahan Minyak Bumi
    public function isOperatorMB()
    {
        $user = $this->loadUser(Yii::app()->user->id);
        if($user)
        {
            if($user->role_id==3)
            {
                return true;
            }
        }
        return false;
    }
    //Validate Operator Pengolahan Gas Bumi
    public function isOperatorGB()
    {
        $user = $this->loadUser(Yii::app()->user->id);
        if($user)
        {
            if($user->role_id==4)
            {
                return true;
            }
        }
        return false;
    }
    //Validate Operator Pengolahan Gas Bumi
    public function isOperatorHO()
    {
        $user = $this->loadUser(Yii::app()->user->id);
        if($user)
        {
            if($user->role_id==5)
            {
                return true;
            }
        }
        return false;
    }
    
}
?>
